<?php

namespace App\Admin\Eloquent;

class ProfitRole extends Model
{
  /**
   * 分润角色代码类别
   *
   * @var string
   */
  const PROFIT_ROLE_CODE = 'profits_role';
  const PROFIT_STAGE_CODE='profits_stage';

  /**
   * 模型使用数据库表
   *
   * @var string
   */
  protected $table = 'profits_roles';

  /**
   * 实例化模型可批量赋值
   *
   * @var array
   */
  protected $fillable = ['profit_id','stage','role', 'scale'];

  /**
   * 分润角色
   *
   * @return \App\Admin\Eloquent\Code
   */
  public function role()
  {
    return Code::findByCodeAndTypeId($this->role, self::PROFIT_ROLE_CODE);
  }

  /**
   * 分润阶段
   * @return \App\Admin\Eloquent\Code
   */
  public function stage(){
    return Code::findByCodeAndTypeId($this->stage, self::PROFIT_STAGE_CODE);
  }


}